package buda.tabWidget;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

import android.os.AsyncTask;

 public class TwitterAsyncTask extends AsyncTask<URL, Void, String> 
 {
     protected String doInBackground(URL... urls) 
	{
		HttpURLConnection connection;
		BufferedReader reader;
		try
		{
			connection = (HttpURLConnection) urls[0].openConnection();
			reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
		}
		catch (IOException ex)
		{
			ex.fillInStackTrace();
			Logger.Warning(Logger.Tags.Twitter, "Could not open connection to Twitter.", ex);
			return null;
		}
				
		String result="";
		String inputLine;
		
		try
		{
			while ((inputLine = reader.readLine()) != null)
				result+=(inputLine);
		}
		catch (IOException ex)
		{
			ex.fillInStackTrace();
			Logger.Warning(Logger.Tags.Twitter, "Could not completely read Twitter connection.", ex);
		}

		return result;
	}
 }
